﻿//Copyright (c) 2010 Christopher E. S. King (http://chriskingconsulting.com)
//
//Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files 
// (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, 
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do 
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

using System;
using System.Xml.Linq;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Text;
using System.Globalization;
using System.Collections;

using King.Infoset.Schema;

//                  infoset     metadata        runtime
//              +--------------------------------------
// object       |   object      XsXsdAnyType    ConstraintsGCD
// complex      |   <===== cls\struct =====>    udt
// simple       |   string      cls\struct      udt
// enum         |   <======== enum ========>    udt
// list         |   IEnum<str>  static class    udt
// xml          |   <========== XElement ============>
// IEnumerable  |   <======== IEnumerable ===========>

namespace King.Infoset {

    [XsObjectContract(SchemaName = "anyType", IsPrimitive = true, DeserializedType = typeof(object))]
    public abstract class XsAnyType {
        internal XsAnyType() { }
    }

    [XsXmlContract(SchemaName = "xml", IsPrimitive = true, DeserializedType = typeof(XElement))]
    public class XsXml {
        internal XsXml() { }
    }

    [XsEnumerationContract(SchemaName = "enumeration", IsPrimitive = true, DeserializedType = typeof(IEnumerable<object>))]
    public class XsEnumeration {
    }

    [XsSimpleContract(SchemaName = "anySimpleType")]
    public abstract class XsAnySimpleType : XsAnyType {
        internal XsAnySimpleType() { }

        public object Value { get; set; }
    }

    [XsStringContract(SchemaName = "string", IsPrimitive = true)]
    public class XsString : XsAnySimpleType {
    }

    [XsBooleanContract(SchemaName = "boolean", IsPrimitive = true)]
    public class XsBoolean : XsAnySimpleType {
    }

    [XsDecimalContract(SchemaName = "decimal", IsPrimitive = true)]
    public class XsDecimal : XsAnySimpleType {
    }

    [XsDecimalContract(typeof(int), SchemaName = "integer")]
    public class XsInteger : XsDecimal {
    }

    [XsDecimalContract(typeof(long), SchemaName = "long", IsPrimitive = true)]
    public class XsLong : XsInteger {
    }

    [XsDecimalContract(typeof(int), SchemaName = "int", IsPrimitive = true)]
    public class XsInt : XsLong {
    }
}
